package com.design.graduation.asdemo.utils;

import android.app.ProgressDialog;
import android.content.Context;

/**
 * Created by liyugang on 7/5/15.
 */
public class LoadingUtils {

    private static ProgressDialog dialog;
    private static Context mContext;

    public static void show(Context context, String message) {
        if (mContext != context) {
            mContext = context;
            dialog = new ProgressDialog(context);
            dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            dialog.setCancelable(true);
        }
        dialog.setMessage(message);
        if (!dialog.isShowing()) {
            dialog.show();
        }
    }

    /**
     * This method is to dismiss the progress dialog.
     */
    public static void dismiss() {
        if (dialog == null) {
            return;
        }
        if (dialog.isShowing()) {
            dialog.dismiss();
        }
    }
}

